package com.example.vo;


import lombok.Data;

import java.io.Serializable;

/**
 * <p>Title: ${file_name}</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2020</p>
 * <p>Company: www.baidudu.com</p>
 *
 * @author suke
 * @version 1.0
 * @date ${date}
 */
@Data
public class ResponseData<T> implements Serializable {
    private Meta meta = new Meta();
    private T data;

    public static ResponseData ok() {
        ResponseData resp = new ResponseData<>();
        resp.meta.setStatus(ResultEnums.OK.getStatus());
        resp.meta.setMsg(ResultEnums.OK.getMsg());
        return resp;
    }

    public static <T> ResponseData ok(T t) {
        ResponseData resp = new ResponseData<>();
        resp.meta.setStatus(ResultEnums.OK.getStatus());
        resp.meta.setMsg(ResultEnums.OK.getMsg());
        resp.setData(t);
        return resp;
    }

    public static <T> ResponseData ok(ResultEnums re){
        ResponseData resp = new ResponseData<>();
        resp.meta.setStatus(re.getStatus());
        resp.meta.setMsg(re.getMsg());
        return resp;
    }

    public static ResponseData fail() {
        ResponseData resp = new ResponseData<>();
        resp.meta.setStatus(ResultEnums.ADMIN_LOGIN_FAIL.getStatus());
        resp.meta.setMsg(ResultEnums.ADMIN_LOGIN_FAIL.getMsg());
        return resp;
    }

    public static <T> ResponseData fail(ResultEnums re){
        ResponseData resp = new ResponseData<>();
        resp.meta.setStatus(re.getStatus());
        resp.meta.setMsg(re.getMsg());
        return resp;
    }

}
